package com.xls.box2023.customcontrol;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.xls.box2023.R;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author lhx
 * @description:
 * @date : 2024/2/17 14:43
 */
public class ErrDialog extends Dialog {

    private TextView dialog_text;
    String hint="";

    public ErrDialog(Context context, String hint) {
        super(context);
        setCancelable(true);
        this.hint=hint;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setContentView(R.layout.dialog_err);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        initView();
    }

    private void initView() {
        dialog_text = findViewById(R.id.dialog_text);
        dialog_text.setText(hint);

    }

    final Timer t = new Timer();
    @Override
    public void show() {
        super.show();
        t.schedule(new TimerTask() {
            public void run() {
                if (this!=null&&isShowing()){
                    dismiss();
                }
                if (t!=null){
                    t.cancel();
                }
            }
        }, 3000);
    }
}


